<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>单个附件导入</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/dtree/dtree.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/dtree/font/iconfont.css"/>
</head>
<style type="text/css">
    .layui-form{width:380px;height:300px; margin:15px 0 0 15px}
    .layui-upload-choose{width:257px;height:36px;border:1px solid #ddd;border-radius:4px;line-height:36px; display: inline-block;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;}
    .layui-inline{ position: absolute;top:0;left:0}
    .layui-form-item span.xzexcel{ display: inline-block;color:#666; position: absolute; right:5px; top:5px; background:#5FB878; padding: 5px 12px; border-radius:4px; color:#fff;}
    .prompt{color:#666;font-size:12px; border-top:1px dashed #eee;  padding:15px 0;border-bottom:1px dashed #eee;}
    .prompt span{color:#ff3a3a;font-size:16px;}

</style>
<body>
<div class="page-content-wrap clearfix">
    <form class="layui-form" style="position:relative;">
        <span class=" layui-upload-choose" placeholder="未选择任何文件" ></span>
        <button type="button" class="layui-btn layui-btn-normal" id="selectFile" style="margin-left:4px;">选择文件</button>
        <div class="layui-form-item center" style="margin-top:20px;" >
            <input type="hidden" value="" id="result" />
                <button class="layui-btn layui-btn-normal" type="button" id="submitBtn">提交</button>
                <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                <button type="button" style="display:none;" class="layui-btn layui-btn-normal" id="save"></button>

        </div>
    </form>
</div>


<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery','upload','dialog'], function () {
        var dialog = layui.dialog,
            $ = layui.jquery,
            upload = layui.upload;
            upload.render({
                elem: '#selectFile'
                ,url: '/sysFile/singleFile'
                , data: {catalog: 'base/sysFile', objectId: '${objectId}'}
                ,auto: false
                ,bindAction:'#submitBtn'
                ,accept:'file'
                ,before:function(obj){
                    layer.load();
                }
                ,done:function(result){
                    layer.closeAll('loading');
                    if(result.code==0){
                        $("#result").val(JSON.stringify(result.data));
                        $("#save").click();
                    }else{
                        dialog.msg(result.msg);
                    }

                }
                ,error:function(){
                    layer.closeAll('loading');
                }
            });
    });
</script>
</body>

</html>